/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.NoteDefaultWordManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ 
/*    */ public class UpdateNoteDefaultWord extends AbstractAction
/*    */ {
/* 23 */   private int id = 0;
/*    */ 
/*    */   public UpdateNoteDefaultWord(AbstractHttpServlet servlet) {
/* 26 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public UpdateNoteDefaultWord(AbstractHttpServlet servlet, String id) {
/* 30 */     super(servlet);
/* 31 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 38 */     String defaultword = Util.getURLParameter(request
/* 39 */       .getParameter("defaultword"));
/* 40 */     User user = super.getLoginUser(request);
/* 41 */     response.setContentType("text/html;charset=utf-8");
/* 42 */     PrintWriter out = response.getWriter();
/*    */ 
/* 44 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 46 */     NoteDefaultWordManager manager = new NoteDefaultWordManager();
/*    */     try {
/* 48 */       manager.update(this.id, defaultword, user.userId);
/* 49 */       CompanyInfo company = super.getCompany(user.companyId);
/* 50 */       company.noteDefaultWords = manager.list(user.companyId);
/* 51 */       jsonObject.put("error", "0");
/*    */     } catch (DBException e) {
/* 53 */       jsonObject.put("error", "1");
/*    */     } catch (SQLException e) {
/* 55 */       jsonObject.put("error", "1");
/*    */     }
/* 57 */     out.println(jsonObject);
/* 58 */     out.flush();
/* 59 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateNoteDefaultWord
 * JD-Core Version:    0.6.1
 */